home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / Thread.h,v < prev    next >
Text File  |  1989-10-24  |  4KB  |  263 lines

  1. head     3.3;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.3; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 3.3
  10. date     89.10.24.13.08.38;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.2;
  13.  
  14. 3.2
  15. date     89.02.20.15.37.49;  author grunwald;  state Exp;
  16. branches ;
  17. next     3.1;
  18.  
  19. 3.1
  20. date     88.12.20.13.50.25;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.10.30.13.06.13;  author grunwald;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.09.18.16.42.15;  author grunwald;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 3.3
  40. log
  41. @*** empty log message ***
  42. @
  43. text
  44. @// This may look like C code, but it is really -*- C++ -*-
  45. // 
  46. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  47. //
  48. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  49. //
  50. #ifndef    THREADH
  51. #define    THREADH
  52. #pragma once
  53.  
  54. #include <Awesime.h>
  55. #include <HardwareContext.h>
  56. #include <ThreadContainer.h>
  57. #include <stream.h>
  58.  
  59. enum ThreadState { SUSPENDED, RUNNING, RUNNABLE, ZOMBIED, TERMINATED };
  60.  
  61. static const double NullTime = -1;
  62.  
  63. typedef int ThreadPriority;
  64.  
  65. class CpuMultiplexor;
  66. class SingleCpuMux;
  67. class MultiCpuMux;
  68. class SimulationMultiplexor;
  69.  
  70. class Thread : public Awesime {
  71.  
  72.     friend class CpuMultiplexor;
  73.     friend class SingleCpuMux;
  74.     friend class MultiCpuMux;
  75.     friend class SimulationMultiplexor;
  76.  
  77.     HardwareContext pContext;
  78.  
  79.     ThreadState threadState;
  80.     ThreadPriority threadPriority;
  81.     short cpuAffinity;
  82.  
  83.     ThreadContainer suspendedOn;
  84.  
  85.     void startOff();
  86.     void makeTerminated();
  87.     char* threadName;
  88.  
  89. protected:
  90.  
  91.     void name(char *);
  92.     void state(ThreadState s);
  93.  
  94.     void makeRunnable();
  95.  
  96.     virtual void main();
  97.  
  98. public:
  99.     Thread(char* name ="", unsigned stacksize = 1010,
  100.        ThreadPriority priority = 0,
  101.        bool debug = 0, int checkStack = 1);
  102.     
  103.     virtual ~Thread();
  104.  
  105.     //
  106.     // access functions
  107.     //
  108.     
  109.     const HardwareContext * context();
  110.     char* name();
  111.     ThreadState state();
  112.  
  113.     long maxStackDepth();
  114.     void checkStack();
  115.  
  116.     void priority(ThreadPriority newPriority);
  117.     ThreadPriority priority();
  118.  
  119.     //
  120.     // action functions
  121.     //
  122.     
  123.     virtual void classPrintOn(ostream& strm);
  124. };
  125.  
  126. inline char*
  127. Thread::name()
  128. {
  129.     return threadName;
  130. }
  131.  
  132. inline void
  133. Thread::name(char *name)
  134. {
  135.     threadName = name;
  136. }
  137.  
  138. inline void
  139. Thread::state(ThreadState s)
  140. {
  141.     threadState = s;
  142. }
  143.  
  144. inline ThreadState
  145. Thread::state()
  146. {
  147.     return threadState;
  148. }
  149.  
  150. inline long
  151. Thread::maxStackDepth()
  152. {
  153.     return( pContext.maxStackDepth() );
  154. }
  155.  
  156. inline void
  157. Thread::checkStack()
  158. {
  159.     pContext.checkStack();
  160. }
  161.  
  162. inline ThreadPriority
  163. Thread::priority()
  164. {
  165.     return(threadPriority);
  166. };
  167.  
  168. inline void
  169. Thread::priority(ThreadPriority newPriority)
  170. {
  171.     threadPriority = newPriority;
  172. }
  173. #endif    THREADH
  174. @
  175.  
  176.  
  177. 3.2
  178. log
  179. @Start using Gnu library heaps for schedulers
  180. @
  181. text
  182. @d9 1
  183. d11 4
  184. a14 4
  185. #include "Awesime.h"
  186. #include "HardwareContext.h"
  187. #include "ThreadContainer.h"
  188. #include "stream.h"
  189. d18 2
  190. d23 2
  191. d30 2
  192. d58 1
  193. a58 1
  194.        int debug = 0, int checkStack = 1);
  195. @
  196.  
  197.  
  198. 3.1
  199. log
  200. @Steay version
  201. @
  202. text
  203. @@
  204.  
  205.  
  206. 1.2
  207. log
  208. @*** empty log message ***
  209. @
  210. text
  211. @d31 1
  212. d62 1
  213. d64 2
  214. d104 6
  215. @
  216.  
  217.  
  218. 1.1
  219. log
  220. @Initial revision
  221. @
  222. text
  223. @d1 6
  224. d19 2
  225. a20 1
  226. class HardwareCpu;
  227. d24 2
  228. a25 1
  229.     friend class HardwareCpu;
  230. a28 1
  231.     const char* threadName;
  232. d36 1
  233. d40 2
  234. a41 4
  235.     inline ThreadState state(ThreadState s) {
  236.     threadState = s;
  237.     return s;
  238.     }
  239. d48 1
  240. a48 1
  241.     Thread(const char* name ="", unsigned stacksize = 1010,
  242. d50 1
  243. a50 1
  244.        int debug = 0);
  245. d59 1
  246. a59 1
  247.     const char* name();
  248. d62 1
  249. a63 1
  250.     ThreadPriority priority(ThreadPriority newPriority);
  251. d72 1
  252. a72 1
  253. inline const char*
  254. d78 12
  255. d108 1
  256. a108 1
  257. inline ThreadPriority
  258. a110 1
  259.     ThreadPriority t = threadPriority;
  260. a111 1
  261.     return(t);
  262. @
  263.